FILES=xml.o io.o simple.o callbacks.o clipboard.o crypt.o error.o gui_al.o gui_io.o journal.o  months.o threads.o settings.o search.o meta_functions.o images.o interface.o prefDialogue.o support.o time.o plugins.o journ_wzrd.o prefix.o about.o login.o structure.o tabs.o calendar.o cryptography.o srch_pane.o second.o menu.o status.o dict.o list.o thrd.o diary.o
SUBDIRLIBS=xmldict.o

GTK=`pkg-config gtk+-2.0 --cflags` `pkg-config gthread-2.0 --cflags`
LIBGCRYPT=`libgcrypt-config --cflags `
LLIBGCRYPT=`libgcrypt-config --libs`
LGTK=`pkg-config gtk+-2.0 --libs` `pkg-config gthread-2.0 --libs`

export CC=gcc

all: $(FILES) $(SUBDIRLIBS) objs.d 


clean:
	rm -Rf *.o
	rm -f objs.d
	rm -f libejourn.so
	rm -f ejourn


objs.d: ejourn libejourn.so


xmldict.o: 
	cd xmldict && make


ejourn: libejourn.so main.o
	$(CC) $(LFLAGS) -o ejourn -L. -lejourn $(LGTK)  $(LLIBGCRYPT) main.o

libejourn.so: $(FILES) $(SUBDIRLIBS)
	$(CC) $(LFLAGS) -shared -Wl,-soname,libejourn.so.1 -o libejourn.so $(FILES) $(SUBDIRLIBS)



about.o: about.c
	$(CC) $(CFLAGS) $(GTK) -c about.c

#cli_main.o: cli_main.c
#	$(CC) $(CFLAGS) $(GTK) -c cli_main.c

callbacks.o: callbacks.c
	$(CC) $(CFLAGS) $(GTK) -c callbacks.c

calendar.o: calendar.c
	$(CC) $(CFLAGS) $(GTK) -c calendar.c 

clipboard.o: clipboard.c
	$(CC) $(CFLAGS)  $(GTK) -c clipboard.c

crypto.o: crypto.c
	$(CC) $(CFLAGS) $(LIBGCRYPT) -c crypt.c

cryptography.o: cryptography.c
	$(CC) $(CFLAGS) $(GTK) -c cryptography.c

diary.o: diary.c
	$(CC) $(CFLAGS) -c diary.c -DNO_GUI

dict.o: dict.c
	$(CC) $(CFLAGS) $(GTK) -c dict.c

error.o: error.c
	$(CC) $(CFLAGS)  $(GTK) -c error.c 

export.o: export.c
	$(CC) $(CFLAGS) -c export.c

fileChooser.o: fileChooser.c
	$(CC) $(CFLAGS) $(GTK) -c fileChooser.c

gui_al.o: gui_al.c
	$(CC) $(CFLAGS) $(GTK) -c gui_al.c

gui_io.o: gui_io.c
	$(CC) $(CFLAGS) $(GTK)-c gui_io.c

handler.o: handler.c 
	$(CC) $(CFLAGS) -c handler.c

images.o: images.c
	$(CC) $(CFLAGS) -c images.c

interface.o: interface.c
	$(CC) $(CFLAGS) $(GTK) -c interface.c

io.o: io.c
	$(CC) $(CFLAGS) -c io.c

journal.o: journal.c
	$(CC) $(CFLAGS) -c journal.c $(GTK)

journ_wzrd.o: journ_wzrd.c
	$(CC) $(CFLAGS) -c journ_wzrd.c $(GTK)

#listen.o: listen.c
#	$(CC) $(CFLAGS) $(GTK) -c listen.c

list.o: list.c
	$(CC) $(CFLAGS) $(GTK) -c list.c

login.o: login.c
	$(CC) $(CFLAGS) $(GTK) -c login.c

main.o: main.c
	$(CC) $(CFLAGS) $(GTK) -c main.c

menu.o: menu.c
	$(CC) $(CFLAGS) `pkg-config gtk+-2.0 --cflags` `pkg-config gthread-2.0 --cflags` -c menu.c

meta_functions.o: meta_functions.c
	$(CC) $(CFLAGS) -c meta_functions.c

months.o: months.c
	$(CC) $(CFLAGS) -c months.c

prefDialogue.o: prefDialogue.c
	$(CC) $(CFLAGS) $(GTK) -c prefDialogue.c

prefix.o: prefix.c
	$(CC) $(CFLAGS) -c prefix.c -DENABLE_BINRELOC -lpthread

plugins.o: plugins.c
	$(CC) $(CFLAGS) -c plugins.c

search.o: search.c
	$(CC) $(CFLAGS) $(GTK) -c search.c


second.o: second.c
	$(CC) $(CFLAGS) -c second.c

settings.o: settings.c
	$(CC) $(CFLAGS) -c settings.c

simple.o: simple.c
	$(CC) $(CFLAGS) -c simple.c

srch_pane.o: srch_pane.c
	$(CC) $(CFLAGS) $(GTK) -c srch_pane.c

status.o: status.c
	$(CC) $(CFLAGS) $(GTK) -c status.c

structure.o: structure.c
	$(CC) $(CFLAGS) -c structure.c

support.o: support.c
	$(CC) $(CFLAGS) $(GTK) -c support.c

tabs.o: tabs.c
	$(CC) $(CFLAGS) -c tabs.c $(GTK) 

#talk.o: talk.c
#	$(CC) $(CFLAGS) $(GTK) -c talk.c

time.o: time.c
	$(CC) $(CFLAGS) -c time.c

threads.o: threads.c
	$(CC) $(CFLAGS) -c threads.c

xml.o: xml.c
	$(CC) $(CFLAGS) -c xml.c
